import { apiGet } from "@/utils/request";
import { defineStore } from "pinia";

export default defineStore("schedule", () => {
  // 获取影院的影片排期
  const get = async (cinemaId: number | string) => {
    const { films } = await apiGet<{
      films: IFilm[];
    }>("mall.film-ticket.film.cinema-show-film", {
      cinemaId,
    });
    return films;
  };

  // 获取影院的影片的日期的具体场次排期
  const getList = async (
    cinemaId: number | string,
    filmId: number | string,
    date: number | string
  ) => {
    const { schedules } = await apiGet<{ schedules: ISchedule[] }>(
      "mall.film-ticket.schedule.list",
      {
        cinemaId,
        filmId,
        date,
      }
    );

    return schedules;
  };

  return {
    get,
    getList,
  };
});
